Skip to content

Conversation

@gregfromstl
Copy link
Contributor

@gregfromstl gregfromstl commented Dec 3, 2024

CNCT-2303

Woah. This is sick.


PR-Codex overview

This PR focuses on updating the thirdweb package to improve transaction serialization by using the ox library, along with refactoring and renaming some files and functions for consistency.

Detailed summary

  • Renamed coinbaseWebSDK.js to coinbase-web.js across multiple files.
  • Updated imports for parseTypedData to use parse-typed-data.js.
  • Introduced SerializableTransaction type in various files.
  • Added SignableMessage type definition.
  • Implemented parseTypedData function to handle hex chainId.
  • Updated sign, signTransaction, and signTypedData functions to use ox library for signing.
  • Refactored tests to align with new implementations and types.
  • Implemented error handling in keyless transaction methods.
  • Enhanced Coinbase wallet functionalities with mobile provider support.

The following files were skipped due to too many changes: packages/thirdweb/src/adapters/ethers5.test.ts, packages/thirdweb/src/utils/hashing/hashTypedData.ts, packages/thirdweb/src/wallets/coinbase/coinbase-web.test.ts, packages/thirdweb/src/transaction/serialize-transaction.ts, packages/thirdweb/src/transaction/serialize-transaction.test.ts, pnpm-lock.yaml

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@changeset-bot
Copy link

changeset-bot bot commented Dec 3, 2024

🦋 Changeset detected

Latest commit: 16e5347

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
thirdweb Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Dec 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 6, 2024 10:30pm
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 6, 2024 10:30pm
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 6, 2024 10:30pm
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 6, 2024 10:30pm

@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 3, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge-queue” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 41.13 KB (-10.05% 🔽) 823 ms (-10.05% 🔽) 762 ms (-75.76% 🔽) 1.6 s
thirdweb (cjs) 104.48 KB (-1.67% 🔽) 2.1 s (-1.67% 🔽) 2.7 s (-56.19% 🔽) 4.8 s
thirdweb (minimal + tree-shaking) 4.37 KB (-21.76% 🔽) 88 ms (-21.76% 🔽) 136 ms (-73.95% 🔽) 223 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 48 ms (+5.42% 🔺) 58 ms
thirdweb/react (minimal + tree-shaking) 16.94 KB (-9.59% 🔽) 339 ms (-9.59% 🔽) 384 ms (-38.56% 🔽) 723 ms

@codecov
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 85.77586% with 33 lines in your changes missing coverage. Please review.

Project coverage is 48.16%. Comparing base (406c885) to head (16e5347).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../thirdweb/src/transaction/serialize-transaction.ts 88.09% 10 Missing ⚠️
...ages/thirdweb/src/wallets/coinbase/coinbase-web.ts 11.11% 8 Missing ⚠️
.../thirdweb/src/utils/signatures/signature-to-hex.ts 82.60% 4 Missing ⚠️
.../thirdweb/src/utils/any-evm/keyless-transaction.ts 90.00% 3 Missing ⚠️
...s/thirdweb/src/wallets/coinbase/coinbase-wallet.ts 0.00% 2 Missing ⚠️
packages/thirdweb/src/adapters/ethers6.ts 0.00% 1 Missing ⚠️
...s/thirdweb/src/wallets/eip5792/get-calls-status.ts 0.00% 1 Missing ⚠️
...s/thirdweb/src/wallets/eip5792/get-capabilities.ts 0.00% 1 Missing ⚠️
...ackages/thirdweb/src/wallets/eip5792/send-calls.ts 0.00% 1 Missing ⚠️
.../thirdweb/src/wallets/eip5792/show-calls-status.ts 50.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5598      +/-   ##
==========================================
+ Coverage   47.86%   48.16%   +0.30%     
==========================================
  Files        1088     1089       +1     
  Lines       56667    56875     +208     
  Branches     4314     4361      +47     
==========================================
+ Hits        27122    27395     +273     
+ Misses      28847    28780      -67     
- Partials      698      700       +2     
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (ø) Carriedforward from 406c885
packages 44.02% <85.77%> (+0.39%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
packages/thirdweb/src/adapters/ethers5.ts 53.28% <100.00%> (+13.86%) ⬆️
...b/src/react/web/utils/usePreloadWalletProviders.ts 43.05% <100.00%> (ø)
.../transaction/actions/gasless/providers/biconomy.ts 55.44% <ø> (ø)
...rc/transaction/actions/gasless/providers/engine.ts 35.88% <ø> (ø)
...nsaction/actions/gasless/providers/openzeppelin.ts 48.41% <ø> (ø)
...irdweb/src/transaction/actions/sign-transaction.ts 100.00% <100.00%> (+17.64%) ⬆️
...transaction/actions/to-serializable-transaction.ts 76.19% <100.00%> (ø)
.../src/transaction/actions/zksync/getEip721Domain.ts 4.68% <ø> (ø)
packages/thirdweb/src/utils/hashing/hashMessage.ts 75.00% <100.00%> (-25.00%) ⬇️
...ckages/thirdweb/src/utils/hashing/hashTypedData.ts 97.93% <100.00%> (+0.01%) ⬆️
... and 23 more

);
});

test("domain: chainId hex", async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the removed test?

const result = await isValidSignature({
contract: options.contract,
hash: hashTypedData(options.data),
hash: ox__TypedData.hashStruct({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh types clashed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I'm just trying to use ox as much as possible in the underlying functions, so we don't need to wrap and/or rewrite internal utils we're not planning to export

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i meant the casts underneath this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes they do

@@ -0,0 +1,5 @@
---
"thirdweb": patch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would make this a minor - lots of underlying changes

@@ -1,11 +1,13 @@
import type { TransactionSerializable } from "viem";
import * as ox__Hash from "ox/Hash";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious why you dont just import { Hash } from 'ox' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cjs won't treeshake properly if I do, have to import it this way

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really? ugh


const tx = parseTransaction(serialized);
const tx = ox__TransactionEnvelopeEip1559.deserialize(
serialized as ox__TransactionEnvelopeEip1559.Serialized,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will these cast go away once we migrate everything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are just the tests being extra picky because I'm allowing legacy transactions

Copy link
Contributor Author

gregfromstl commented Dec 6, 2024

Merge activity

  • Dec 6, 5:21 PM EST: The merge label 'merge-queue' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Dec 6, 5:21 PM EST: A user added this pull request to the Graphite merge queue.
  • Dec 6, 5:32 PM EST: A user merged this pull request with the Graphite merge queue.

CNCT-2303

Woah. This is sick.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on updating the `thirdweb` package to enhance transaction serialization by integrating the `ox` library, renaming files, and refactoring code for better consistency in handling typed data and signatures.

### Detailed summary
- Replaced instances of `coinbaseWebSDK.js` with `coinbase-web.js`.
- Updated the `parseTypedData` function to handle hex `chainId`.
- Refactored signature handling in various files to use `ox` library.
- Introduced new types and updated existing ones for better type safety.
- Added tests for `parseTypedData` functionality.
- Adjusted imports across multiple files to reflect new structure.
- Enhanced error handling and validation for typed data signatures.

> The following files were skipped due to too many changes: `packages/thirdweb/src/adapters/ethers5.test.ts`, `packages/thirdweb/src/utils/hashing/hashTypedData.ts`, `packages/thirdweb/src/wallets/coinbase/coinbase-web.test.ts`, `packages/thirdweb/src/transaction/serialize-transaction.ts`, `packages/thirdweb/src/transaction/serialize-transaction.test.ts`, `pnpm-lock.yaml`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-queue Adds the pull request to Graphite's merge queue. packages SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants